From b060715deb11baa409276a148e4af8306624568a Mon Sep 17 00:00:00 2001 From: Michael Natterer Date: Thu, 12 Jan 2006 13:50:51 +0000 Subject: [PATCH] connect to the display's "closed" signal and free the cached scratch 2006-01-12 Michael Natterer * gdk/gdkimage.c (scratch_image_info_for_depth): connect to the display's "closed" signal and free the cached scratch images upon display closing (bug #85715). --- ChangeLog | 6 ++++++ ChangeLog.pre-2-10 | 6 ++++++ gdk/gdkimage.c | 23 +++++++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/ChangeLog b/ChangeLog index 5cae63ecb3..f2b9139a57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-01-12 Michael Natterer + + * gdk/gdkimage.c (scratch_image_info_for_depth): connect to the + display's "closed" signal and free the cached scratch images upon + display closing (bug #85715). + 2006-01-12 Michael Natterer * gtk/gtkexpander.c (gtk_expander_set_expanded): skip the diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index 5cae63ecb3..f2b9139a57 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,3 +1,9 @@ +2006-01-12 Michael Natterer + + * gdk/gdkimage.c (scratch_image_info_for_depth): connect to the + display's "closed" signal and free the cached scratch images upon + display closing (bug #85715). + 2006-01-12 Michael Natterer * gtk/gtkexpander.c (gtk_expander_set_expanded): skip the diff --git a/gdk/gdkimage.c b/gdk/gdkimage.c index a2744261a2..db47ebe361 100644 --- a/gdk/gdkimage.c +++ b/gdk/gdkimage.c @@ -226,6 +226,25 @@ allocate_scratch_images (GdkScratchImageInfo *info, return TRUE; } +static void +scratch_image_info_display_closed (GdkDisplay *display, + gboolean is_error, + GdkScratchImageInfo *image_info) +{ + gint i; + + g_signal_handlers_disconnect_by_func (display, + scratch_image_info_display_closed, + image_info); + + scratch_image_infos = g_slist_remove (scratch_image_infos, image_info); + + for (i = 0; i < image_info->n_images; i++) + g_object_unref (image_info->static_image[i]); + + g_free (image_info); +} + static GdkScratchImageInfo * scratch_image_info_for_depth (GdkScreen *screen, gint depth) @@ -249,6 +268,10 @@ scratch_image_info_for_depth (GdkScreen *screen, image_info->depth = depth; image_info->screen = screen; + g_signal_connect (gdk_screen_get_display (screen), "closed", + G_CALLBACK (scratch_image_info_display_closed), + image_info); + /* Try to allocate as few possible shared images */ for (i=0; i < G_N_ELEMENTS (possible_n_images); i++) { -- 2.30.2